

use "$temp/extendedcosts.dta"

* All regressions
log using "$logfiles/regressions_all_up.log", replace
foreach j in icent ifcc yocent yofcc{

******* a) State dummies only *******
reg `j' i.stateid
estimates store e_`j'_a
predict p_`j'_a

******* b) State dummies and linear trends *******
reg `j' year i.stateid
estimates store e_`j'_b
predict p_`j'_b

******* b1) State dummies and linear trends + interaction *******
reg `j' year i.stateid c.year#stateid
estimates store e_`j'_b1
predict p_`j'_b1

***************** Combinations with wages ********************************************

foreach k in cps_cpkt cps_cc{

******* c) Childcare worker wages only *******
reg `j' `k' 
estimates store e_`j'_c_`k'
predict p_`j'_c_`k'

*******  d) Child care worker wages and state dummies ******* 
reg `j' `k' i.stateid
estimates store e_`j'_d_`k'
predict p_`j'_d_`k'

******* e) Child care worker wages, state dummies, and linear year trends *******
reg `j' `k' year i.stateid
estimates store e_`j'_e_`k'
predict p_`j'_e_`k'

******* e1) Child care worker wages, state dummies, and linear year trends + interaction *******
reg `j' `k' year i.stateid c.year#stateid
estimates store e_`j'_e1_`k'
predict p_`j'_e1_`k'

}
}
log close

order  stateid year icent p_icent* ifcc p_ifcc* yocent p_yocent* yofcc p_yofcc*  cps_cc cps_cpkt

* Creating the summary tables
log using "$logfiles/tables_all_up.log", replace
foreach m in icent ifcc yocent yofcc{
foreach n in cps_cpkt cps_cc{
estimates table e_`m'_a e_`m'_b e_`m'_b1 e_`m'_c_`n' e_`m'_d_`n' e_`m'_e_`n' e_`m'_e1_`n', se stats(r2 r2_a N) k(year `n') ti(`m', wages are: `n') 
}
}
log close

drop _est*

***************************************************************
* save main p_extendedcosts.dta/csv data sets for main analysis

save "$data_der/p_extendedcosts.dta", replace

drop state_year

export delimited using "$data_der/p_extendedcosts.csv", nolabel replace


* Erase some temporary data sets

erase "$temp/extendedcosts.dta"


clear
